package com.lagou.homework.third;

/**
 * 上网套餐类
 */
public class InternetPackage extends AbstractPackage implements InternetInterface {
    /**
     * 上网流量
     */
    private double traffic;

    /**
     * 无参构造方法
     */
    public InternetPackage() {
    }

    /**
     * 有参构造方法
     * @param traffic
     * @param monthlyCost
     */
    public InternetPackage(double traffic, double monthlyCost) {
        super(monthlyCost);
        setTraffic(traffic);
    }

    public double getTraffic() {
        return traffic;
    }

    public void setTraffic(double traffic) {
        if (traffic >= 0.0) {
            this.traffic = traffic;
        } else {
            System.out.println("上网流量数值不合理");
        }
    }

    @Override
    public void show() {
        System.out.println("上网流量：" + getTraffic() + "，每月资费：" + getMonthlyCost());
    }

    @Override
    public void test(double traffic, PhoneCard phoneCard) {
        phoneCard.show();
        setTraffic(traffic);
        show();
    }
}
